Graph modeling is the process of abstracting complex real-world relationships (such as internet routing or state transitions) into a mathematical object $G = (V, E)$. By defining entities asvertices (Vertex) and relationships asedges (Edge), we can leverage a unified abstract data type (ADT) and algorithms to solve diverse problems.
Core Component Definitions
- vertices (Vertex): Also known as nodes. They have a "key" (Key) for unique identification and may carry a "payload" (Payload).
- edges (Edge): Connects two vertices, indicating a relationship between them. It can be unidirectional (directed graph) or bidirectional.
- Weight (Weight): A numerical value on an edge representing cost (e.g., distance, latency, bandwidth).
Mathematical Rigor
Mathematically, $G = (V, E)$. Here, $V$ is the set of vertices, and $E$ is the set of ordered pairs $(v, w)$ forming edges, where $v, w \in V$. This highly abstract structure allows us to use the same BFS/DFS algorithms to solve problems ranging from map navigation to social network recommendations.
Modeling Insight: State Space Graph
When solving logic puzzles (such as the water jug problem), eachvalid stateis a vertex, and eachvalid operationis an edge. Solving the problem involves finding a path from the initial vertex to the target vertex.